// window.onresize = function () {
//   console.log('resized')
// }

export function notification (message, type, duration, res) {
  if (isObject(res)) {
    let notification = {
      mes: message || '提交错误',
      mesType: type || 'error',
      mesDuration: duration || 5000
    }
    if (res.status === 0) {
      notification.mes = res.data
      notification.mesType = 'success'
      notification.mesDuration = 10000
    } else if (res.status === 1000) {
      notification.mesType = 'warning'
      notification.mesDuration = 5000
      notification.mes = res.message
    } else {
      notification.mesType = 'error'
      notification.mesDuration = 5000
      if (res.status === 2000) {
        notification.mes = res.message
      }
    }

    return notification
  }
}

function isObject (obj) {
  return typeof obj === 'object' && obj != null
}
